<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //1、已知persons用户信息数据：
         let persons = [
            { "username": "xiaoming1", "password": "1111" },
            { "username": "xiaoming2", "password": "222" },
            { "username": "xiaoming3", "password": "33333" }
        ];
        //现有
        let user = { username:"xiaoming",password:"34433" }
           let tt=persons.some(function(item){
              return item.username===user.username;
            });
            if(tt){
                console.log('注册的账户已经存在');
                
            }else{
                persons .push(user);
            }
            console.log(persons);
           //注册原理：如果persons中没有对应的用户，则把user追加到persons末尾
    
    </script>
</body>
</html>